   //Mouse.inc by SANiK
   //License: Use as you wish, except to cause damage
   unsigned char mouse_cycle=0;     //unsigned char
   char mouse_int[3];    //signed char
   char mouse_x=0;         //signed char
   char mouse_y=0;         //signed char
   //Mouse functions
   void mouse_handler(struct regs *a_r) //struct regs *a_r (not used but just there)
   {
     switch(mouse_cycle)
     {
       case 0:
         mouse_int[0]=inb(0x60);
         mouse_cycle++;
         break;
       case 1:
         mouse_int[1]=inb(0x60);
         mouse_cycle++;
         break;
       case 2:
         mouse_int[2]=inb(0x60);
         mouse_x=mouse_int[1];
         mouse_y=mouse_int[2];
         mouse_cycle=0;
         break;
     }
   }
   inline void mouse_wait(int a_type) //unsigned char
   {
     long _time_out=100000; //unsigned int
     if(a_type==0)
     {
       while(_time_out--) //Data
       {
         if((inb(0x64) & 1)==1)
         {
           return;
         }
       }
       return;
     }
     else
     {
       while(_time_out--) //Signal
       {
         if((inb(0x64) & 2)==0)
         {
           return;
         }
       }
       return;
     }
   }
   inline void mouse_write(int a_write) //unsigned char
   {
     //Wait to be able to send a command
     mouse_wait(1);
     //Tell the mouse we are sending a command
     outb(0x64, 0xD4);
     //Wait for the final part
     mouse_wait(1);
     //Finally write
     outb(0x60, a_write);
   }
   int mouse_read()
   {
     //Get's response from mouse
     mouse_wait(0);
     return inb(0x60);
   }
   void mouse_install()
   {
     unsigned char _status;  //unsigned char
     //Enable the auxiliary mouse device
     mouse_wait(1);
     outb(0x64, 0xA8);

     //Enable the interrupts
     mouse_wait(1);
     outb(0x64, 0x20);
     mouse_wait(0);
     _status=(inb(0x60) | 2);
     mouse_wait(1);
     outb(0x64, 0x60);
     mouse_wait(1);
     outb(0x60, _status);

     //Tell the mouse to use default settings
     mouse_write(0xF6);
     mouse_read();  //Acknowledge

     //Enable the mouse
     mouse_write(0xF4);
     mouse_read();  //Acknowledge
     //Setup the mouse handler
     irq_handler(12, mouse_handler);
   }

